package com.kazusa.myservlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.List;

@WebServlet("/requestScopeTool")
public class RequestScopeTool extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("RequestScopeTool servlet ");
        //获取域对象内容
        String name=(String) request.getAttribute("name");
        System.out.println("name="+name);

        Integer age=(Integer)request.getAttribute("age");
        System.out.println("age="+age);
        List<String>list=(List<String>) request.getAttribute("list");
        if(list!=null&&list.size()>0){
            System.out.println(list.get(0));
        }


    }
}
